package com.example.demo1.controller;

import com.example.demo1.pojo.User;
import com.example.demo1.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController //返回值都是JSON串
@CrossOrigin    //解决跨域问题
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    //根据用户ID查询数据
    @GetMapping("/{id}")
    public SysResult getUserById(@PathVariable Integer id){
        User user = userService.findUserById(id);
        return SysResult.success(user);
    }
}
